<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/7/16
 * Time: 9:41
 */

namespace app\service\traits\model\lines;


use app\admin\model\StoreOrder;
use app\company\model\Warehouse;
use app\company\model\WarehouseArea;
use app\company\model\WarehouseStorage;
use app\company\model\WarehouseStorageGoodsLogs;
use app\company\model\WarehouseTakeStock;
use app\company\model\WarehouseTakeStockGoods;
use app\mini\model\StoreOrderDetail;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
use think\model\relation\HasManyThrough;
use think\model\relation\HasOne;


/**
 *  仓库
 * Trait Warehouse
 * Trait Deliver
 * @property  Warehouse $warehouse
 * @property  Warehouse $warehouses
 * @property  WarehouseArea $warehouseArea
 * @property  WarehouseArea $warehouseAreas
 * @property  WarehouseArea $warehouseAreaSM
 * @property  WarehouseStorage $warehouseStorage
 * @property  WarehouseStorage $warehouseStorages
 * @property  WarehouseStorage $warehouseStorageSM
 * @property  WarehouseTakeStock $warehouseTakeStock
 * @property  WarehouseTakeStock $warehouseTakeStockO
 * @property  WarehouseTakeStock $warehouseTakeStocks
 * @property  WarehouseTakeStockGoods $WarehouseTakeStockGoods
 * @property  WarehouseTakeStockGoods $WarehouseTakeStockGoodsO
 * @property  WarehouseTakeStockGoods $WarehouseTakeStockGoodss
 */
trait WarehouseLines
{

    /**
     * 关联仓库表
     * @return belongsTo
     */
    public function warehouse(): belongsTo
    {
        return $this->belongsTo(Warehouse::class);
    }

    /**
     * 关联仓库表
     * @return hasMany
     */
    public function warehouses(): hasMany
    {
        return $this->hasMany(Warehouse::class);
    }

    /**
     * 关联仓库库区表
     * @return belongsTo
     */
    public function warehouseArea(): belongsTo
    {
        return $this->belongsTo(WarehouseArea::class);
    }

    /**
     * 关联仓库库区表
     * @return hasMany
     */
    public function warehouseAreas(): hasMany
    {
        return $this->hasMany(WarehouseArea::class);
    }

    /**
     * 关联仓库库区表
     * @return hasManyThrough
     */
    public function warehouseAreaSM(): hasManyThrough
    {
        return $this->hasManyThrough(WarehouseArea::class, Warehouse::class);
    }

    /**
     * 关联仓库库位表
     * @return belongsTo
     */
    public function warehouseStorage(): belongsTo
    {
        return $this->belongsTo(WarehouseStorage::class);
    }

    /**
     * 关联仓库库位表
     * @return hasMany
     */
    public function warehouseStorages(): hasMany
    {
        return $this->hasMany(WarehouseStorage::class);
    }

    /**
     * 关联仓库库位表
     * @return hasManyThrough
     */
    public function warehouseStorageSM(): hasManyThrough
    {
        return $this->hasManyThrough(WarehouseStorage::class, Warehouse::class);
    }

    /**
     * 公司盘点单
     * @return belongsTo
     */
    public function warehouseTakeStock(): belongsTo
    {
        return $this->belongsTo(WarehouseTakeStock::class);
    }

    /**
     * 公司盘点单
     * @return hasMany
     */
    public function warehouseTakeStocks(): hasMany
    {
        return $this->hasMany(WarehouseTakeStock::class);
    }

    /**
     * 公司盘点单
     * @return hasOne
     */
    public function warehouseTakeStockO(): hasOne
    {
        return $this->hasOne(WarehouseTakeStock::class);
    }


    /**
     * 公司盘点单明细
     * @return belongsTo
     */
    public function warehouseTakeStockGoods(): belongsTo
    {
        return $this->belongsTo(WarehouseTakeStockGoods::class);
    }

    /**
     * 公司盘点单明细
     * @return hasMany
     */
    public function warehouseTakeStockGoodss(): hasMany
    {
        return $this->hasMany(WarehouseTakeStockGoods::class);
    }

    /**
     * 公司盘点单明细
     * @return hasOne
     */
    public function warehouseTakeStockGoodsO(): hasOne
    {
        return $this->hasOne(WarehouseTakeStockGoods::class);
    }

    /**
     * 出入库记录表
     * @return belongsTo
     */
    public function warehouseStorageGoodsLogs(): belongsTo
    {
        return $this->belongsTo(WarehouseStorageGoodsLogs::class);
    }

    /**
     * 出入库记录表
     * @return hasMany
     */
    public function warehouseStorageGoodsLogss(): hasMany
    {
        return $this->hasMany(WarehouseStorageGoodsLogs::class);
    }

    /**
     * 出入库记录表
     * @return hasOne
     */
    public function warehouseStorageGoodsLogsO(): hasOne
    {
        return $this->hasOne(WarehouseStorageGoodsLogs::class);
    }

    /**
     * 出入库记录表
     * @param $map
     * @return hasManyThrough
     */
    public function warehouseStorageGoodsLogsStoreOrderSM($map): hasManyThrough
    {
        return $this->hasManyThrough(WarehouseStorageGoodsLogs::class,StoreOrder::class)->where($map);
    }

}